package com.yangrd.helper.crudhelper.common.util;

import java.io.*;

/**
 * description: IoUtils
 *
 * @author: yangrd
 * @date: 2020/9/16
 * @version: 1.0
 */
public class IOUtils {

    /**
     * inputStream 转 str
     *
     * @param in
     * @return
     */
    public static String inputStream2String(InputStream in) {
        InputStreamReader reader = null;
        try {
            reader = new InputStreamReader(in, "UTF-8");
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        }
        BufferedReader br = new BufferedReader(reader);
        StringBuilder sb = new StringBuilder();
        String line = "";
        try {
            while ((line = br.readLine()) != null) {
                sb.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return sb.toString();
    }
}
